package com.drone.drone_server.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.drone.drone_server.entity.*;
import com.drone.drone_server.dto.*;
import org.apache.ibatis.annotations.*;

import java.util.List;


// 无人机行为计划DAO


public interface DroneActionDao extends BaseMapper<DroneAction> {
    @Select("SELECT * FROM drone_action WHERE schedule_type = #{type} AND enabled = TRUE")
    List<DroneAction> selectActiveByScheduleType(@Param("type") String type);

    @Select("SELECT a.drone_action_id AS droneActionId, " +
            "a.drone_id AS droneId, " +
            "a.route_id AS routeId, " +
            "a.start_time AS startTime, " +
            "a.schedule_type AS scheduleType, " +
            "a.which_day AS whichDay, " +
            "a.enabled AS enabled, " +
            "r.route_name AS routeName, " +
            "r.coordinates AS coordinates " +
            "FROM drone_action a " +
            "JOIN drone_route r ON a.route_id = r.route_id ")
    @Results({
            @Result(property = "droneActionId", column = "droneActionId"),
            @Result(property = "droneId", column = "droneId"),
            @Result(property = "routeId", column = "routeId"),
            @Result(property = "startTime", column = "startTime"),
            @Result(property = "scheduleType", column = "scheduleType"),
            @Result(property = "whichDay", column = "whichDay"),
            @Result(property = "enabled", column = "enabled"),
            @Result(property = "routeName", column = "routeName"),
            @Result(property = "coordinates", column = "coordinates")
    })
    List<DroneActionAndRoute> selectAllDroneActionAndRoute();
}
